<%@ Page Language="C#" MasterPageFile="~/default.master" Title="Untitled Page" %>
<%@ Register TagPrefix="Common" TagName="Pager" Src="~/Controls/Pager.ascx" %>
<%@ import Namespace="Memories" %>
<%@ import Namespace="Memories.Entities" %>
<script runat="server">


    string path = "";
    Settings settings;
    string folderName = "";
    string comment = "";
    
	void Page_Load(Object sender, EventArgs e) {
        settings = (Settings)Context.Items["Settings"];
        path = (string)Context.Items["Path"];

        MyPager.PageSize = settings.PageSize;
        MyPager.LinkTemplate = settings.UrlFormatter.GetFolderViewPagerTemplate(path);
        MyPager.SelectedLinkTemplate = "[{0}] ";

        
        Folder folder = MemoriesDB.GetFolder(settings,path);
        
        comment = folder.Comment;
        folderName = folder.Name;

        ImageList.DataSource = MemoriesDB.GetPagedFiles(folder, MyPager.CurrentPageNo, MyPager.PageSize, ref MyPager.PageCount);
        ImageList.DataBind();

        if (folder.Folders.Count > 0)
        {
            FolderList.DataSource = folder.Folders;
            FolderList.DataBind();
        }

        this.Title = settings.Title + " : " + folder.Name;
   }

    
</script>
<asp:Content ContentPlaceHolderID="PageHeader" runat="server">
    <h2><%=folderName %></h2>
</asp:Content>
<asp:Content ContentPlaceHolderID="ContentWrapper" runat="server">
   
    <div id="contentpane">	
	    <% if (MyPager.CurrentPageNo < 2){%>
	    <div class="comment">
	        <%=comment%>
	    </div>
	    <%} %>
	    <asp:DataList RepeatColumns="7" RepeatDirection="Horizontal" 
		    id="ImageList" runat="server" EnableViewState="false" 
		    cellpadding="2" CellSpacing="1" style="width:100%">
	        <ItemStyle CssClass="imagecell" />
	        <ItemTemplate>
		        <a href="<%#settings.UrlFormatter.GetImageViewUrl((string)Eval("RelativePath")) %>">
		            <img alt="<%# Eval("Title")%>" src="<%#settings.UrlFormatter.GetImageUrl((string)Eval("RelativePath"),80) %>" />
		        </a>
	        </ItemTemplate>
        </asp:DataList>
        <Common:Pager id="MyPager" runat="server" PageSize="42" PageNoQueryString="page" />
	    <asp:Repeater id="FolderList" runat="server">
		    <ItemTemplate>
		    <tr>
		        <td><a href="<%#settings.UrlFormatter.GetFolderViewUrl((string)Eval("RelativePath"))%>"><%#Eval("Name") %></a></td>
		        <td><%# ((Folder)Container.DataItem).Files.Count.ToString() %></td>
		        <td><%# ((Folder)Container.DataItem).Folders.Count.ToString() %></td>
		    </tr>
		    </ItemTemplate>
		    <HeaderTemplate>
		        <h3><%# String.Format((string)GetGlobalResourceObject("Localization", "albumsin_1_"),folderName)%></h3>
		        <table cellpadding="2" cellspacing="1" class="tabulardata">
		        <tr>
		            <th><%=GetGlobalResourceObject("Localization", "album")%></th>
		            <th><%=GetGlobalResourceObject("Localization", "images")%></th>
		            <th><%=GetGlobalResourceObject("Localization", "subalbums")%></th>
		        </tr>
		    </HeaderTemplate>
		    <FooterTemplate></table></FooterTemplate>
	    </asp:Repeater>
	</div>
</asp:Content>
